﻿using SqlSugar;
using System.Linq;

namespace AlipayPay.Infrastructure.EntitiyExtensions
{
    public class QueryBase<T> : IQuery<T> where T : class,new()
    {
        private ISqlSugarClient _db;
        private readonly IUnitOfWork _unitOfWork;

        // 构造函数，通过 unitofwork，来控制sqlsugar 实例
        public QueryBase(IUnitOfWork unitOfWork)
        {
            _unitOfWork = unitOfWork;
            _db = unitOfWork.GetDbClient();
        }

        /// <summary>
        /// 获取IQueryable
        /// </summary>
        /// <returns></returns>
        public ISugarQueryable<T> GetQueryable()
        {
            return _db.Queryable<T>();
        }
    }
}
